
var rn = "\r\n"; 
var hwx =  "#fEffect/CharacterEff/1032063/0/0#"; 
var selectionData = [0, 0]
 var itemList = [ 

[5000201,20],
[5000202,20],
[5000203,20],
[5000204,20],
[5000205,20],
[5000206,20],
[5000207,20],
[5000208,20],
[5000209,25],
[5000210,20],
[5000211,20],
[5000212,30],
[5000213,30],
[5000214,30],
[5000215,20],
[5000216,20],
[5000217,20],
[5000221,20],

[5000225,25],

[5000227,10],
[5000228,25],
[5000229,25],
[5000230,25],
[5000231,25],
[5000232,25],
[5000233,25],

[5000237,15],
[5000238,15],
[5000239,10],
[5000240,20],

[5000243,25],
[5000244,25],
[5000245,25],



[5000249,25],
[5000250,25],
[5000251,25],
[5000247,25],
[5000252,25],
[5000253,25],

[5000255,20],
[5000256,20],
[5000257,20],
[5000258,20],


[5000261,20],


[5000264,10],


[5000267,1],
[5000268,10],
[5000269,10],
[5000270,20],
[5000271,20],
[5000272,20],
[5000273,20],
[5000274,10],
[5000275,10],
[5000276,10],
[5000277,10],

[5000281,15],
[5000282,15],
[5000283,15],
[5000284,15],
[5000285,20],

[5000287,10],
[5000288,10],
[5000289,10],
[5000290,25],
[5000291,25],
[5000292,25],
[5000293,20],
[5000294,20],
[5000295,20],
[5000296,20],
[5000297,20],
[5000298,20],

[5000300,25],
[5000301,25],
[5000302,25],
[5000303,25],
[5000304,25],
[5000305,25],
[5000306,25],
[5000307,25],
[5000308,25],
[5000309,25],
[5000310,10],
[5000311,10],




[5000316,20],
[5000317,20],

[5000320,20],
[5000321,20],
[5000322,20],

[5000324,10],


[5000328,25],

[5000330,25],
[5000331,20],
[5000332,20],

[5000341,10],
[5000342,10],
[5000343,10],
[5000344,10],
[5000345,10],

[5000352,10],
[5000353,10],
[5000354,10],

[5000358,10],

[5000365,10],
[5000366,10],
[5000367,10],
[5000368,5],
[5000369,10],
[5000370,15],
[5000371,20],


[5000375,10],
[5000376,10],
[5000377,10],

[5000381,20],
[5000382,10],
[5000383,20],
//
[5000385,10],
[5000386,10],
[5000387,10],
[5000388,10],
[5000389,10],
[5000390,10],
[5000391,10],
[5000393,10],

[5000402,10],
[5000403,10],
[5000404,10],
[5000405,20],
[5000406,20],
[5000407,20],
[5000408,10],
[5000409,10],


[5000414,10],
[5000415,20],
[5000416,20],
[5000417,15],
//
[5000424,20],
[5000425,10],
[5000426,10],
[5000427,10],
[5000428,10],
[5000429,10],
[5000430,10],
[5000431,10],
[5000432,10],
[5000433,30],
[5000434,30],
[5000435,30],

[5000437,10],

[5000443,10],
[5000444,10],
[5000445,10],
[5000446,10],
[5000447,10],
[5000448,10],

[5000452,10],
//

[5000460,20],
[5000461,20],
[5000462,20],

[5000466,10],

[5000468,10],
[5000469,10],
[5000470,10],
[5000471,10],




//

[5000473,10],
[5000474,1],
[5000475,1],
[5000476,10],
[5000479,10],
[5000483,10],
[5000528,10],
[5000529,10],
[5000541,10],
[5000606,10],
[5000616,10],
[5001000,10],
[5001001,10],
[5001002,10],
[5001003,10],
[5001004,10],
[5001005,10],
[5001006,20],
[5001007,20],
[5001008,20],
[5001009,30],
[5001010,30],
[5001011,30],
[5001012,20],
[5001013,20],
[5001014,20],
[5001015,30],
[5001016,30],
[5001017,30]

]
var status = 0;
function start() {
	status = -1;
	action(1, 0, 0);
}
function action(mode, type, selection) {
    if (mode === -1) {
        cm.dispose();
    } else {
        if (status >= 0 && mode === 0) {
           
            cm.dispose();
            return;
        }

        status = status + (mode === 1 ? 1 : -1);

        if (status === 0) {
            showMenu();
        } else if (status === 1) {
				seletionData=itemList[selection];
				var text = "#d确定要使用【"+itemList[selection][1]+"】余额购买#v"+itemList[selection][0]+"##z"+itemList[selection][0]+"##l吗，在这之前请确认背包是否有足够空间。#k\r\n";
				cm.sendYesNo("" + text + "");
        } else if (status === 2) {
			
            if (cm.getInventory(2).isFull()||cm.getInventory(1).isFull(1)){
				cm.sendOk("请保证背包#b特殊栏#k至少有 #r1 #k个位置");
				cm.dispose();
				return;
			}
			if (cm.getBossRankCount("赞助余额") >= seletionData[1]) {
				cm.gainPet(seletionData[0], cm.getItemName(seletionData[0]), 1, 0, 100, 30*86400, 0); 
				cm.setBossRankCount("赞助余额", -seletionData[1]);
				cm.sendOk("恭喜购买成功，获得 #v"+seletionData[0]+"##z"+seletionData[0]+"##r * 1");
				cm.dispose();
			} else {
				cm.sendOk("赞助余额不足，无法购买。");
				cm.dispose();
			}
        }
    }
}
/**
 * 显示菜单
 */
 function showMenu() {
    var text ="\t\t\t" + hwx + "#r#e < 宠物商店 > #k#n" + hwx + "\r\n\r\n\r\n";

	text+="当前有:"+cm.getBossRankCount("赞助余额")+" 余额"+rn;
    for (var i = 0; i < itemList.length; i++) {
        text += "\t#L"+i+"##d【"+itemList[i][1]+"】余额 购买#v"+itemList[i][0]+"##z"+itemList[i][0]+"##l\r\n";
    }
    cm.sendNext("" + text + "");
}
